/*
 * Created by JFormDesigner on Thu Oct 28 08:08:16 GMT+08:00 2021
 */

package hpasUserInterfaces.userLoginPage;

import java.awt.*;
import javax.swing.*;
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import hpasControllers.UserLoginController;

/**
 * @author laeva
 */
public class UserLogin extends JFrame {
    public UserLogin()
    {
        initComponents();
        addListener();
    }

    private void addListener()
    {
        loginController=new UserLoginController();
        loginController.setUsername(textField1);
        loginController.setPass(textField2);
        loginController.setBtLogin(button1);
        loginController.setBtGuestLogin(button2);
        loginController.setParent(this);
        button1.addActionListener(loginController);
        button2.addActionListener(loginController);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        panel1 = new JPanel();
        label1 = new JLabel();
        label2 = new JLabel();
        label3 = new JLabel();
        textField1 = new JTextField();
        textField2 = new JPasswordField();
        button1 = new JButton();
        button2 = new JButton();
        button3 = new JButton();
        label4 = new JLabel();
        label5 = new JLabel();

        //======== this ========
        setMinimumSize(new Dimension(485, 380));
        setResizable(false);
        setTitle("\u767b\u5f55");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container contentPane = getContentPane();
        contentPane.setLayout(new GridLayout());

        //======== panel1 ========
        {

            //---- label1 ----
            label1.setText("\u6b22\u8fce\u4f7f\u7528\u786c\u4ef6\u62a5\u4ef7\u67e5\u8be2\u7cfb\u7edf");
            label1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 28));

            //---- label2 ----
            label2.setText("\u7528\u6237\u540d");

            //---- label3 ----
            label3.setText("\u5bc6\u7801");

            //---- button1 ----
            button1.setText("\u767b\u5f55");

            //---- button2 ----
            button2.setText("\u6e38\u5ba2\u767b\u5f55");

            //---- button3 ----
            button3.setText("\u6ce8\u518c");

            //---- label4 ----
            label4.setText("\u00a9Copyright 2021 AHNU-CS-SE2 7th Group \"ISLANDERS\"");
            label4.setHorizontalAlignment(SwingConstants.CENTER);

            //---- label5 ----
            label5.setText("All right reserved.");
            label5.setHorizontalAlignment(SwingConstants.CENTER);

            GroupLayout panel1Layout = new GroupLayout(panel1);
            panel1.setLayout(panel1Layout);
            panel1Layout.setHorizontalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGroup(panel1Layout.createParallelGroup()
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addGap(66, 66, 66)
                                .addComponent(label1))
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addGap(35, 35, 35)
                                .addGroup(panel1Layout.createParallelGroup()
                                    .addGroup(panel1Layout.createSequentialGroup()
                                        .addComponent(button1, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
                                        .addGap(41, 41, 41)
                                        .addComponent(button3, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                                        .addComponent(button2, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(panel1Layout.createSequentialGroup()
                                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(label3, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(label2, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGap(18, 18, Short.MAX_VALUE)
                                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                            .addComponent(textField1, GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                                            .addComponent(textField2, GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)))
                                    .addComponent(label5, GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)
                                    .addComponent(label4, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE))))
                        .addGap(41, 41, 41))
            );
            panel1Layout.setVerticalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(label1)
                        .addGap(59, 59, 59)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label2)
                            .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label3)
                            .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(button1, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
                            .addComponent(button2, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
                            .addComponent(button3, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(label4)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label5)
                        .addContainerGap(11, Short.MAX_VALUE))
            );
        }
        contentPane.add(panel1);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JPanel panel1;
    private JLabel label1;
    private JLabel label2;
    private JLabel label3;
    private JTextField textField1;
    private JPasswordField textField2;
    private JButton button1;
    private JButton button2;
    private JButton button3;
    private JLabel label4;
    private JLabel label5;
    private UserLoginController loginController;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
